package com.um.jdy.platform.financial.controller;


import com.um.jdy.platform.financial.entity.dto.MemberBillExportDTO;
import com.um.jdy.platform.financial.entity.dto.MemberBillPageDTO;
import com.um.jdy.platform.financial.entity.vo.UserBillItemVO;
import com.um.jdy.platform.financial.manager.MemberUserBillManager;
import com.um.springboot.starter.annotation.ApiPermission;
import com.um.springboot.starter.annotation.LoginRequired;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.controller.BaseController;
import com.um.springboot.starter.orm.entity.Response;
import com.um.springboot.starter.orm.params.ExportParams;
import com.um.springboot.starter.orm.params.PageParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 控制器：用户流水表
 */
@RestController
@RequestMapping("/api/v1/cms/finance/user_bill")
@Api(tags = "UserBillController", description = "用户流水表")
@ApiPermission("user_bill")
@LoginRequired
public class MemberUserBillController extends BaseController<MemberUserBillManager> {

    /**
     * 分页查询用户流水
     * @param params
     * @return
     */
    @ApiPermission("page")
    @ApiOperation("用户流水分页")
    @PostMapping("/bill_page")
    public Response<Page<UserBillItemVO>> getBillPage(@RequestBody MemberBillPageDTO params){
        PageParams pageParams = params.toPageParams(
                new String[]{"no","type","event","orderNo","outTradeNo","mobile"},
                new String[]{"a.no","a.type","a.event","a.order_no","a.out_trade_no","u.mobile"},
                "a.create_time","beginTime","endTime");
        return manager.getBillPage(pageParams);
    }

    /**
     * 导出业务员流水
     *
     * @param params
     * @return
     */
    @ApiPermission("export")
    @ApiOperation("用户流水导出")
    @PostMapping("/export_bill_page")
    public Response exportBillPage(@RequestBody MemberBillExportDTO params){
        ExportParams exportParams = params.toExportParams(
                new String[]{"no","type","event","orderNo","outTradeNo","mobile"},
                new String[]{"a.no","a.type","a.event","a.order_no","a.out_trade_no","u.mobile"},
                "a.create_time","beginTime","endTime");
        return manager.exportBillPage(exportParams);
    }

}
